﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;

namespace SkyReader
{
    public partial class Settings : PhoneApplicationPage
    {
        public Settings()
        {
            InitializeComponent();

            string[] AccentColors = { "Black", "Blue", "Brown", "Cyan", "DarkGray", "Gray", "Green", "LightGray", "Magenta", "Orange", "Purple", "Red",  "White", "Yellow" };
            DataContext = AccentColors;
            this.lstBackgroundColor.SelectedItem = "Black";
            this.lstFontColor.SelectedItem = "White";

            
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            if (settings.Contains("SETTINGS_BACKGROUNDCOLOR"))
            {
                this.lstBackgroundColor.SelectedItem = settings["SETTINGS_BACKGROUNDCOLOR"];
            }

            if (settings.Contains("SETTINGS_FONTCOLOR"))
            {
                this.lstFontColor.SelectedItem = settings["SETTINGS_FONTCOLOR"];
            }
        }

        private void SaveButton_Click(object sender, EventArgs e)
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            settings["SETTINGS_BACKGROUNDCOLOR"] = this.lstBackgroundColor.SelectedItem;
            settings["SETTINGS_FONTCOLOR"] = this.lstFontColor.SelectedItem;
            settings.Save();

            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

        private void CancelButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }


    }
}